<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Chameleon-Mini: The Chameleon Command Structure</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Chameleon-Mini
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="index.html">index</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">The Chameleon Command Structure </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>After plugging in a USB cable, the ChameleonMini enumerates as a virtual serial interface. The settings of the serial interface, e.g. baudrate, stop and parity bits, are ignored by the Chameleon. For a high level of compatibility towards both humans and computers, Chameleon can be set up and controlled by means of a text-based command line interface, which can be accessed by using simple terminal software like hyper-terminal or teraterm. The command line is optimized to cooperate with script languages such as Python or TCL.</p>
<dl class="section note"><dt>Note</dt><dd>Before reading this page, you may also wish to have a look at the <a href="https://play.google.com/store/apps/details?id=com.maxieds.chameleonminilivedebugger">Chameleon Android App</a>, which is an external contribution to this project. Development and maintenance can be found <a href="https://github.com/maxieds/ChameleonMiniLiveDebugger">here</a> (please also ask questions regarding the app there).</dd></dl>
<h1>Chameleon Command Structure </h1>
<p>For communicating with the Chameleon via USB, there exist four different syntax types:</p><ul>
<li><code>&lt;COMMAND&gt;=&lt;VALUE&gt;</code> sets a parameter of the Chameleon ('set')</li>
<li><code>&lt;COMMAND&gt;=?</code> lists all possible values for the parameter ('suggest')</li>
<li><code>&lt;COMMAND&gt;?</code> returns the current value of a parameter ('get')</li>
<li><code>&lt;COMMAND&gt;</code> Executes a function with an optional response ('execute')</li>
</ul>
<p>For example, <code>CONFIG=?</code> lists the available types of virtualized cards and other options to configure a slot, while <code>CONFIG=MF_CLASSIC_1K</code> sets the current slot to Mifare Classic 1k emulation. In consequence, <code>CONFIG?</code> will return MF_CLASSIC_1K. Examples for commands executing a function are CLEAR, RESET or UPLOAD.</p>
<p>The responses of Chameleon indicate whether an action was successful or whether (and why) an error occurred. Examples: In case of an invalid command, the Chameleon replies with <code>200:UNKNOWN COMMAND</code>. In case of a known command, but a wrong syntax, the Chameleon replies with <code>201:INVALID COMMAND USAGE</code>.</p>
<p>Note: Each command has to be followed by a carriage return (CR, 0D hexadecimal). The backspace (08 hexadecimal) and escape (1B hexadecimal) keys are supported. All other control characters of the ASCII character set are ignored. The Chameleon commands are not case-sensitive. There is no echo of entered characters by the Chameleon, thus remember to switch on the 'local echo' in your terminal program.</p>
<h2>Responses </h2>
<p>Subsequent to any command sent, the Chameleon responds with a status number and a corresponding status message, separated by a colon and terminated with a carriage return and line feed (CR+LF, 0D+0A hexadecimal). Status numbers are of a three-digit decimal format with the first digit showing the severity of the answer. Status numbers beginning with a '1' denote an informational item and those beginning with a '2' denote an error. </p><table class="doxtable">
<tr>
<th>Response </th><th>Description  </th></tr>
<tr>
<td><code>100:OK</code> </td><td>The command has been successfully executed </td></tr>
<tr>
<td><code>101:OK WITH TEXT</code> </td><td>The command has been successfully executed and this response is appended with an additional line of information, terminated with CR+LF </td></tr>
<tr>
<td><code>110:WAITING FOR XMODEM</code> </td><td>The Chameleon is waiting for an XMODEM connection to be established </td></tr>
<tr>
<td><code>120:FALSE</code> </td><td>The request is answered with false </td></tr>
<tr>
<td><code>121:TRUE</code> </td><td>The request is answered with true </td></tr>
<tr>
<td><code>200:UNKNOWN COMMAND</code> </td><td>This command is unknown to the Chameleon </td></tr>
<tr>
<td><code>201:INVALID COMMAND USAGE</code> </td><td>This action is not supported by this command </td></tr>
<tr>
<td><code>202:INVALID PARAMETER</code> </td><td>The format or value of the given parameter value is invalid </td></tr>
<tr>
<td><code>203:TIMEOUT</code> </td><td>The timeout of the currently active command has expired </td></tr>
</table>
<h1>Chameleon Command Set </h1>
<p>The current firmware supports the following global commands. </p><table class="doxtable">
<tr>
<th>Command </th><th>Description  </th></tr>
<tr>
<td><code>CHARGING?</code> </td><td>Returns if the battery is currently being charged (TRUE) or not (FALSE) </td></tr>
<tr>
<td><code>HELP</code> </td><td>Returns a comma-separated list of all commands supported by the current firmware </td></tr>
<tr>
<td><code>RESET</code> </td><td>Reboots the Chameleon, i.e., power down and subsequent power-up. Note: A reset usually requires a new Terminal session. </td></tr>
<tr>
<td><code>RSSI?</code> </td><td>Returns the voltage measured at the antenna of the Chameleon, e.g., to detect the presence of an RF field or compare the field strength of different RFID readers. </td></tr>
<tr>
<td><code>SYSTICK?</code> </td><td>Returns the system tick value in ms. Note: An overflow occurs every 65,536 ms. </td></tr>
<tr>
<td><code>UPGRADE</code> </td><td>Sets the Chameleon into firmware upgrade mode (DFU). This command can be used instead of holding the RBUTTON while power-on to trigger the bootloader. </td></tr>
<tr>
<td><code>VERSION?</code> </td><td>Requests version information of the current firmware </td></tr>
<tr>
<td><b>Button Commands</b></td><td>See also <a class="el" href="Page_Buttons.html">Buttons</a> </td></tr>
<tr>
<td><code>RBUTTON=?</code> </td><td>Returns a comma-separated list of supported actions for pressing the right button shortly. </td></tr>
<tr>
<td><code>RBUTTON?</code> </td><td>Returns the currently set action for pressing the right button shortly. DEFAULT: <code>SETTING_CHANGE</code> </td></tr>
<tr>
<td><code>RBUTTON=&lt;NAME&gt;</code> </td><td>Sets the action for pressing the right button shortly. </td></tr>
<tr>
<td><code>LBUTTON=?</code> </td><td>Returns a comma-separated list of supported actions for pressing the left button shortly. </td></tr>
<tr>
<td><code>LBUTTON?</code> </td><td>Returns the currently set action for pressing the left button shortly. DEFAULT: <code>RECALL_MEM</code> </td></tr>
<tr>
<td><code>LBUTTON=&lt;NAME&gt;</code> </td><td>Sets the action for pressing the left button shortly. </td></tr>
<tr>
<td><code>RBUTTON_LONG=?</code> </td><td>Returns a comma-separated list of supported actions for pressing the right button a long time. </td></tr>
<tr>
<td><code>RBUTTON_LONG?</code> </td><td>Returns the currently set action for pressing the right button a long time. DEFAULT: <code>SETTING_CHANGE</code> </td></tr>
<tr>
<td><code>RBUTTON_LONG=&lt;NAME&gt;</code> </td><td>Sets the action for pressing the right button a long time. </td></tr>
<tr>
<td><code>LBUTTON_LONG=?</code> </td><td>Returns a comma-separated list of supported actions for pressing the left button a long time. </td></tr>
<tr>
<td><code>LBUTTON_LONG?</code> </td><td>Returns the currently set action for pressing the left button a long time. DEFAULT: <code>RECALL_MEM</code> </td></tr>
<tr>
<td><code>LBUTTON_LONG=&lt;NAME&gt;</code> </td><td>Sets the action for pressing the left button a long time. </td></tr>
<tr>
<td><b>LED Commands</b> </td><td>See also <a class="el" href="Page_LED.html">LED functionality</a> </td></tr>
<tr>
<td><code>LEDGREEN=?</code> </td><td>Returns a comma-separated list of supported events for illuminating the green LED </td></tr>
<tr>
<td><code>LEDGREEN?</code> </td><td>Returns the currently set event for lighting the green LED </td></tr>
<tr>
<td><code>LEDGREEN=&lt;NAME&gt;</code> </td><td>Sets the event for which the green LED is lit. DEFAULT: <code>POWERED</code> </td></tr>
<tr>
<td><code>LEDRED=?</code> </td><td>Returns a comma-separated list of supported events for illuminating the red LED </td></tr>
<tr>
<td><code>LEDRED?</code> </td><td>Returns the currently set event for lighting the red LED </td></tr>
<tr>
<td><code>LEDRED=&lt;NAME&gt;</code> </td><td>Sets the event for which the green LED is lit. DEFAULT: <code>SETTING_CHANGE</code> </td></tr>
<tr>
<td><b>Log Commands</b> </td><td>See also <a class="el" href="Page_Log.html">Log functionality</a><a class="anchor" id="Anchor_LogFunctions"></a></td></tr>
<tr>
<td><code>LOGMODE=?</code> </td><td>Returns a comma-separated list of supported log modes </td></tr>
<tr>
<td><code>LOGMODE?</code> </td><td>Returns the current state of the log mode </td></tr>
<tr>
<td><code>LOGMODE=&lt;NAME&gt;</code> </td><td>Sets the current log mode. DEFAULT = <code>OFF</code> </td></tr>
<tr>
<td><code>LOGMEM?</code> </td><td>Returns the remaining free space for logging data to the SRAM (max. 2048 byte) </td></tr>
<tr>
<td><code>LOGDOWNLOAD</code> </td><td>Waits for an XModem connection and then downloads the binary log - including any log data in FRAM. </td></tr>
<tr>
<td><code>LOGCLEAR</code> </td><td>Clears the log memory (SRAM and FRAM) </td></tr>
<tr>
<td><code>LOGSTORE</code> </td><td>Writes the current log from SRAM to FRAM and clears the SRAM log. <dl class="section warning"><dt>Warning</dt><dd>If the FRAM is full, currently no error message is shown. If calling <code>LOGMEM?</code> after executing this command returns any other value than the maximum SRAM log size, there was not sufficient space in the FRAM and nothing has been done. </dd></dl>
</td></tr>
</table>
<p>ChameleonMini provides eight 'slots' that can be configured to store different virtualized cards, or as active NFC reader, or as completely passive device for sniffing purposes. Each slot stores its configuration and, if applicable, card content. To select a particular slot, use the following command (or configure a button accordingly): </p><table class="doxtable">
<tr>
<th>Command </th><th>Description  </th></tr>
<tr>
<td><code>SETTING?</code> </td><td>Returns the currently activated slot </td></tr>
<tr>
<td><code>SETTING=&lt;NUMBER&gt;</code> </td><td>Sets the active slot, where &lt;NUMBER&gt; is a number between 1 and 8 (see <a class="el" href="Page_Settings.html">Settings</a>) </td></tr>
</table>
<p>The following commands have an effect on the currently selected slot only: </p><table class="doxtable">
<tr>
<th>Command </th><th>Description  </th></tr>
<tr>
<td><code>CONFIG=?</code> </td><td>Returns a comma-separated list of all supported configurations </td></tr>
<tr>
<td><code>CONFIG?</code> </td><td>Returns the configuration of the current slot </td></tr>
<tr>
<td><code>CONFIG=&lt;NAME&gt;</code> </td><td>Sets the configuration of the surrent slot to <code>&lt;NAME&gt;</code> (See <a class="el" href="Page_Configurations.html">Configurations</a>) </td></tr>
<tr>
<td><code>UIDSIZE?</code> </td><td>Returns the UID size of the currently selected card type in Byte </td></tr>
<tr>
<td><code>UID?</code> </td><td>Returns the UID of a card in the current slot </td></tr>
<tr>
<td><code>UID=&lt;UID&gt;</code> </td><td>Sets a new UID, passed in hexadecimal notation. </td></tr>
<tr>
<td><code>READONLY?</code> </td><td>Returns the current state of the read-only mode </td></tr>
<tr>
<td><code>READONLY=[0;1]</code> </td><td>Activates (1) or deactivates (0) the read-only mode (Any writing to the memory is silently ignored) </td></tr>
<tr>
<td><code>MEMSIZE?</code> </td><td>Returns the memory size occupied by the current configuration in Byte </td></tr>
<tr>
<td><code>UPLOAD</code> </td><td>Waits for an XModem connection in order to upload a new virtualized card into the currently selected slot, with a size up to the current memory size </td></tr>
<tr>
<td><code>DOWNLOAD</code> </td><td>Waits for an XModem connection in order to download a virtualized card with the current memory size </td></tr>
<tr>
<td><code>CLEAR</code> </td><td>Clears the content of the current slot </td></tr>
<tr>
<td><code>STORE</code> </td><td>Stores the content of the current slot from FRAM into the Flash memory </td></tr>
<tr>
<td><code>RECALL</code> </td><td>Recalls/restores the content of the current slot from the Flash memory into the FRAM </td></tr>
<tr>
<td><code>TIMEOUT=?</code> </td><td>Returns the possible number range for timeouts. See also <a class="el" href="Page_CommandLine.html#Anchor_TimeoutCommands">Timeout commands</a>. </td></tr>
<tr>
<td><code>TIMEOUT=&lt;NUMBER&gt;</code> </td><td>Sets the timeout for the current slot in multiples of 128 ms. If set to zero, there is no timeout. See also <a class="el" href="Page_CommandLine.html#Anchor_TimeoutCommands">Timeout commands</a>. </td></tr>
<tr>
<td><code>TIMEOUT?</code> </td><td>Returns the timeout for the current slot. See also <a class="el" href="Page_CommandLine.html#Anchor_TimeoutCommands">Timeout commands</a>. </td></tr>
<tr>
<td><b>Reader Commands</b></td><td>Using these commands only makes sense, if the slot is configured as reader. See also <a class="el" href="Page_14443AReader.html">ISO14443A Reader Functionality</a> </td></tr>
<tr>
<td><code>SEND &lt;BYTEVALUE&gt;</code> </td><td>Adds parity bits, sends the given byte string &lt;BYTEVALUE&gt;, and returns the cards answer </td></tr>
<tr>
<td><code>SEND_RAW &lt;BYTEVALUE&gt;</code></td><td>Does NOT add parity bits, sends the given byte string &lt;BYTEVALUE&gt; and returns the cards answer </td></tr>
<tr>
<td><code>GETUID</code> </td><td>Obtains the UID of a card that is in the range of the antenna and returns it. This command is a <a class="el" href="Page_CommandLine.html#Anchor_TimeoutCommands">Timeout command</a>. </td></tr>
<tr>
<td><code>DUMP_MFU</code> </td><td>Reads the whole content of a Mifare Ultralight card that is in the range of the antenna and returns it. This command is a <a class="el" href="Page_CommandLine.html#Anchor_TimeoutCommands">Timeout command</a>. </td></tr>
<tr>
<td><code>CLONE_MFU</code> </td><td>Clones a Mifare Ultralight card that is in the range of the antenna to the current slot, which is then accordingly configured to emulate it. This command is a <a class="el" href="Page_CommandLine.html#Anchor_TimeoutCommands">Timeout command</a>. </td></tr>
<tr>
<td><code>IDENTIFY</code> </td><td>Identifies the type of a card in the range of the antenna and returns it. This command is a <a class="el" href="Page_CommandLine.html#Anchor_TimeoutCommands">Timeout command</a>. </td></tr>
<tr>
<td><code>THRESHOLD=?</code> </td><td>Returns the possible number range for the reader threshold. </td></tr>
<tr>
<td><code>THRESHOLD=&lt;NUMBER&gt;</code> </td><td>Globally sets the reader threshold. The &lt;NUMBER&gt; influences the reader function and range. Setting a wrong value may result in malfunctioning of the reader. DEFAULT: 400 </td></tr>
<tr>
<td><code>THRESHOLD?</code> </td><td>Returns the current reader threshold. </td></tr>
<tr>
<td><code>AUTOCALIBRATE</code> </td><td>Automatically finds a good threshold for communicating with the card that currently is on top of the Chameleon. This command is a <a class="el" href="Page_CommandLine.html#Anchor_TimeoutCommands">Timeout command</a>. </td></tr>
<tr>
<td><code>FIELD?</code> </td><td>Returns whether (1) or not (0) the reader field is active. </td></tr>
<tr>
<td><code>FIELD=[0;1]</code> </td><td>Enables/disables the reader field. </td></tr>
</table>
<h2>Timeout Commands<a class="anchor" id="Anchor_TimeoutCommands"></a></h2>
<p>Some commands start a process with an unpredictable termination time. In these cases, ChameleonMini waits with its response, until the result of this process is obtained. In order to prevent an infinite waiting time, an individual timeout value can be set for each slot, in multiples of roughly 100 ms up to 60,000 ms. When a timeout occurs or if a respective command is aborted by means of a setting change, the return code <code>203:TIMEOUT</code> is sent and a command-specific shutdown function is called, which terminates the timeout process gracefully.</p>
<dl class="section warning"><dt>Warning</dt><dd>Any terminal input is completely ignored during the waiting period.</dd>
<dd>
When setting the timeout to zero, there is no timeout and thus a process may continue forever. Such a process can only be terminated by changing the setting, if a button is configured accordingly, or by restarting the ChameleonMini (power off, power on).</dd></dl>
<h1>Accessing the command-line using a terminal software </h1>
<p>In order to have quick access to the Chameleon's command-line without using any complicated software, we suggest using the <a href="https://ttssh2.osdn.jp/index.html.en">TeraTerm</a> terminal emulation software available for windows based operating systems.</p>
<h2>Connecting and setting up </h2>
<p>For establishing a connection to the Chameleon's command line, select File -&gt; New Connection, choose the virtual serial port of the Chameleon and hit the "OK" button. TeraTerm now tries to open the serial port and should succeed without any error.</p>
<p>For easier use of the command-line using a terminal software the local-echo functionality should be activated, to be able to see what is typed into the chameleon. When using TeraTerm, this can be achieved by selecting Setup -&gt; Terminal and check "Local Echo".</p>
<h2>Uploading and Downloading dump files </h2>
<p>In some configurations of the Chameleon, it is necessary to upload a card dump before it can be accessed by a reader. For doing so, the relatively simple and widely known XMODEM protocol is used.</p>
<p>To upload a dump file using TeraTerm, follow these steps.</p><ol type="1">
<li>Enter <code>UPLOAD</code> and wait for the <code>110:WAITING FOR XMODEM</code> response</li>
<li>Select File -&gt; Transfer -&gt; XMODEM -&gt; Send</li>
<li>In the dialog choose the binary dumpfile to be uploaded and make sure the option "Checksum" is checked in the lower left corner</li>
<li>Hitting the "Open" button will start the transfer. If no error is given to the user, the file has been uploaded sucessfully.</li>
</ol>
<p>To download the Chameleon's memory again, follow the instructions above except for using <code>DOWNLOAD</code> instead of <code>UPLOAD</code> and the Receive function of TeraTerm</p>
<p>Note that there is a 10 second timeout after entering <code>UPLOAD</code> respectively <code>DOWNLOAD</code> after which the standard command-line is activated again. So try again if the timeout is already over when the XMODEM transfer is about to start. </p>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Oct 23 2020 10:47:16 for Chameleon-Mini by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
